server {
    # Скрываем версию nginx от злоумышленников
    server_tokens off;
    # Слушаем порт 80
    listen 80;
    # Список IP, запросы к которым должен обрабатывать nginx
    server_name 62.84.119.85;

    location /media/ {
        root /var/html/;
    }

    location /static/admin/ {
        root /var/html/;
    }

    location /static/rest-framework/ {
        root /var/html/;
    }

    location /api/docs/ {
        root /usr/share/nginx/html;
        try_files $uri $uri/redoc.html;
    }

    location /api/ {
        proxy_set_header        Host $host;
        proxy_set_header        X-Forwarded-Host $host;
        proxy_set_header        X-Forwarded-Server $host;
        proxy_pass http://backend:8000;
    }

    location /admin/ {
        proxy_pass http://backend:8000/admin/;
    }

    location / {
        root /usr/share/nginx/html;
        index  index.html index.htm;
        try_files $uri /index.html;
        proxy_set_header        Host $host;
        proxy_set_header        X-Real-IP $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header        X-Forwarded-Proto $scheme;
      }
      error_page   500 502 503 504  /50x.html;
      location = /50x.html {
        root   /var/html/frontend/;
      }
}
